﻿using System;
using System.Reflection;
using System.Windows.Forms;
using Aeon.Testing.Properties;

using Aeon.Testing.Sounds;
using Aeon.Testing.Models;
using Aeon.Testing.Animations;
using Aeon.Testing.Environment;

namespace Aeon.Testing
{

public partial class WindowMenu : Form
    {
    // --- Fields:
    
    private Boolean isOpen;     // Window already open flag.
    
    // --- Constructor:
    
    public WindowMenu()
        {
        InitializeComponent();
        Icon = Resources.AeonIco;
        
        isOpen = false;
        }
        
    // --- Internal Methods:
    
    private void enableButtons(bool enabled)
        {
        ButtonBuilder.Enabled = enabled;
        ButtonDemoEnv.Enabled = enabled;
        ButtonDemoAni.Enabled = enabled;
        ButtonDemoMdl.Enabled = enabled;
        ButtonDemoSnd.Enabled = enabled;
        }
        
    private void window_Disposed(object sender,EventArgs e)
        {        
        isOpen = false;
        enableButtons(true);
        }
        
    private void window_Created(Type type)
        {
        if (!isOpen)
           {
           ConstructorInfo ctor = type.GetConstructor(Type.EmptyTypes);
           Form window = (Form) ctor.Invoke(null);
           window.Disposed += window_Disposed;
           window.Show();
                      
           isOpen = true;
           enableButtons(false);
           }
        }

    #region Component Event Handlers 

    private void ButtonDemoEnv_Click(object sender,EventArgs e)
        {
        
        window_Created(typeof(WindowDemoEnv));
        }
        
    private void ButtonDemoAni_Click(object sender,EventArgs e)
        {

        window_Created(typeof(WindowDemoAni));
        }

    private void ButtonDemoSnd_Click(object sender, EventArgs e)
        {

        window_Created(typeof(WindowDemoSnd));
        }

    private void ButtonDemoMdl_Click(object sender, EventArgs e)
        {

        window_Created(typeof(WindowDemoMdl));
        }

    private void ButtonBuilder_Click(object sender,EventArgs e)
        {
        
        window_Created(typeof(WindowBuild));
        }

    private void ButtonExit_Click(object sender,EventArgs e)
        {

        this.Close();
        }
        
    #endregion

    }
    
    
}
